package com.gitee.kamismile.disruptorEx.commandhandling.callbacks;

import com.gitee.kamismile.disruptorEx.commandhandling.CommandCallback;
import com.gitee.kamismile.disruptorEx.commandhandling.CommandMessage;
import org.slf4j.LoggerFactory;

public class LoggingCallback implements CommandCallback<Object> {

    protected final org.slf4j.Logger logger = LoggerFactory.getLogger(this.getClass());

    /**
     * The singleton instance for this callback
     */
    public static final LoggingCallback INSTANCE = new LoggingCallback();

    private LoggingCallback() {
    }

    @Override
    public void onSuccess(CommandMessage message, Object result) {
        logger.info("Command executed successfully: {}", message.getCommandName());
    }

    @Override
    public void onFailure(CommandMessage message, Throwable cause) {
        logger.warn("Command resulted in exception: {}", message.getCommandName(), cause);
    }
}
